package com.xiaohu.mayi_huiyuan.controller;

import com.xiaohu.mayi_huiyuan.entity.Usrs;
import com.xiaohu.mayi_huiyuan.service.LoginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    private final static Logger logger = LoggerFactory.getLogger(Exception.class);

    @Autowired
    private LoginService loginService;

    @RequestMapping("/login")
    @ResponseBody
    public String Userlogin(Usrs usrs, HttpSession session){
        logger.info("访问login!");
      Usrs user= loginService.selectUsrs(usrs,session);
      return  user==null?"f":"s";
    }

    @RequestMapping("/")
    public String login(){
        logger.info("进入登录页面");
        return "login";
    }

    @RequestMapping("/index")
    public String inHomePage(){
        return "index";
    }

    @RequestMapping("/500")
    public String error(){
        return "500";
    }


}
